package week_home_work02;

import java.util.Scanner;

/**
 * @author zdl
 * @date 2024/11/23
 */
public class Demo54 {
    public static void main(String[] args) {
        //计算1到n之间的所有数字的奇数和偶数和。
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入一个正整数:");
        int num = sc.nextInt();
        int jiSum = 0;
        int ouSum = 0;
        for (int i = 1; i <= num; i++) {
            if (i % 2 != 0){
                jiSum+=i;
            }
            if (i%2==0){
                ouSum+=i;
            }
        }
        System.out.println("1-"+num+"之间数字的奇数和为"+jiSum);
        System.out.println("1-"+num+"之间数字的偶数和为"+ouSum);
    }
}
